home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / etc / init.d / acpid < prev    next >
Encoding:
Text File  |  2007-03-14  |  2.6 KB  |  101 lines

  1. #! /bin/sh -e
  2.  
  3. # Check for daemon presence
  4. test -x /usr/sbin/acpid || exit 0
  5.  
  6. # Check for ACPI support on kernel side
  7. [ -d /proc/acpi ] || exit 0
  8.  
  9. # Include acpid defaults if available
  10. OPTIONS=""
  11. if [ -f /etc/default/acpid ] ; then
  12.     . /etc/default/acpid
  13. fi
  14.  
  15. # Get lsb functions
  16. . /lib/lsb/init-functions
  17. . /etc/default/rcS
  18.  
  19. if [ "x$VERBOSE" = "xno" ]; then
  20.         MODPROBE_OPTIONS="$MODPROBE_OPTIONS -Q"
  21.         export MODPROBE_OPTIONS
  22. fi
  23.  
  24. # As the name says. If the kernel supports modules, it'll try to load
  25. # the ones listed in "MODULES".
  26. load_modules() {
  27.         PRINTK=`cat /proc/sys/kernel/printk`
  28.         [ "$VERBOSE" = no ] && echo "0 0 0 0" > /proc/sys/kernel/printk
  29.         
  30.         LIST=`/sbin/lsmod|awk '!/Module/ {print $1}'`
  31.  
  32.     # Get list of available modules
  33.         LOC="/lib/modules/`uname -r`/kernel/drivers/acpi"
  34.         LOC2="/lib/modules/`uname -r`/kernel/ubuntu/acpi"
  35.         if [ -d $LOC ]; then
  36.       MODAVAIL=`( find $LOC -type f -name "*.o" -printf "basename %f .o\n"; \
  37.         find $LOC -type f -name "*.ko" -printf "basename %f .ko\n" ) | /bin/sh`
  38.     else
  39.       MODAVAIL=""
  40.     fi
  41.  
  42.         if [ -d $LOC2 ]; then
  43.       MODAVAIL="$MODAVAIL `( find $LOC2 -type f -name "*.o" -printf "basename %f .o\n"; \
  44.         find $LOC2 -type f -name "*.ko" -printf "basename %f .ko\n" ) | /bin/sh`"
  45.     fi
  46.  
  47.         if [ "$MODULES" = "all" ]; then
  48.         MODULES="$MODAVAIL"
  49.         fi
  50.  
  51.     if [ -n "$MODULES" ]; then
  52.         log_begin_msg "Loading ACPI modules..."
  53.         STATUS=0
  54.             for mod in $MODULES; do
  55.             echo $MODAVAIL | grep -q -w "$mod" || continue
  56.                 if echo $LIST | grep -q -w "$mod"; then
  57.                 [ "$VERBOSE" != no ] && log_success_msg "Module already loaded: $mod"
  58.             else
  59.                 if modprobe -b $mod 2>/dev/null; then
  60.                     [ "$VERBOSE" != no ] && log_success_msg "Loaded module: $mod"
  61.                 else
  62.                     if [ "$VERBOSE" != no ]; then
  63.                         log_warning_msg "Unable to load module: $mod"
  64.                     fi
  65.                 fi
  66.             fi        
  67.             done
  68.         log_end_msg $STATUS
  69.     fi
  70.         echo "$PRINTK" > /proc/sys/kernel/printk
  71. }
  72.  
  73. case "$1" in
  74.   start)
  75.     [ -f /proc/modules ] && load_modules
  76.     log_begin_msg "Starting ACPI services..."
  77.     start-stop-daemon --start --quiet --exec /usr/sbin/acpid -- -c /etc/acpi/events $OPTIONS
  78.     log_end_msg $?
  79.     ;;
  80.   stop)
  81.     log_begin_msg "Stopping ACPI services..."
  82.     start-stop-daemon --stop --quiet --oknodo --retry 2 --exec /usr/sbin/acpid
  83.     log_end_msg $?
  84.     ;;
  85.   restart)
  86.     $0 stop
  87.     sleep 1
  88.     $0 start
  89.     ;;
  90.   reload|force-reload) 
  91.     log_begin_msg "Reloading ACPI services..."
  92.     start-stop-daemon --stop --signal 1 --exec /usr/sbin/acpid
  93.     log_end_msg $?
  94.     ;;
  95.   *)
  96.     log_success_msg "Usage: /etc/init.d/acpid {start|stop|restart|reload|force-reload}"
  97.     exit 1
  98. esac
  99.  
  100. exit 0
  101.